// 递归树形数组对象，根据指定字段及传递值删除指定对象
export function removeByField(arr, field, value) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i][field] === value) {
      arr.splice(i, 1)
      i--
    } else if (arr[i].children) {
      removeByField(arr[i].children, field, value)
    }
  }
}

// 写一个uuidhash函数
export function uuidHash(str = Math.random().toExponential(10)) {
  let hash = 0
  for (let i = 0; i < str.length; i++) {
    hash = str.charCodeAt(i) + ((hash << 5) + hash)
  }
  return hash
}
